<?php
/**
 * myHelp.php
 * 
 * (C) 2009, tetsuya.odaka(EzoGP).
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/* 
 * 画面ヘルプの取得を行う
 *  ヘルプは、help/下にユーザーロール別に存在する前提です。
 *      
 *		author	; t.odaka
 *		date	; 2009/5/8
*/
	require("../Myznala/debugLog.php");
	require_once("TextPickup.class.php");
	require_once("../Myznala/MyConverter.class.php");
	
//	$myDebugLog->debug('start'); // Debugログ
	
	// パラメータをサニタイズして配列に入れる。
	require_once("../Myznala/MyConverter.class.php");
	$cObj = new MyConverter();
	$reqParm = $cObj->getRequestParameters();
	
	// 取り出すメニューの名称
	// t.odaka 2009/6/8 fileパラメータをセットすると、それをとってくる
	if(isset($reqParm["file"])){
		$_help = $reqParm["file"];
		if(!file_exists($_help)) $_help = $reqParm["fpath"].'/default.txt';
	}else{
		$_help = $reqParm["fpath"].'/'.$reqParm["fname"].'.txt';
		if(!file_exists($_help)) $_help = $reqParm["fpath"].'/default.txt';
	}
	
//	$myDebugLog->debug('$_help '.$_help);
	
//	$_help = 'help/'.$reqParm["fname"].'.txt';
//	if(!file_exists($_help)) $_help = 'help/default.txt';
	
	// テキストの取り出し
	$ret = null;
	$tObj = new TextPickup();
	$tObj->setFileName($_help);
	$fp = $tObj->fileOpen('r');
	$ret = $tObj->pickupText($fp);
	$tObj->fileClose($fp,'r');

	// 出力
	header("Content-Type:text/html");
	echo($ret);
	
	return;
?>